<?php
/*
	首页
*/

defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['params']['pid']=0;
	$return['list']=array();
	$setting = $return['pluginset'];
	$return['welcomehdps']=$setting['welcomehdps'];
	if(count($setting['welcomehdps'])>0 && $setting['iswelcome']==1){
		$return['iswelcome']=$this->session('iswelcome')?0:1;
		if($return['iswelcome']){
			$this->session('iswelcome',1);
		}
	}
	$groupspram=array('uniacid'=>$_SESSION['uniacid'],'status'=>'1');
	//公告列表
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$notice_list = pdo_getslice('jy_weishop_notice',array('uniacid'=>$_SESSION['uniacid'],'status'=>1),array($pindex,20),$total,array('id','title','createtime'),'','id desc');
	if($notice_list){
		foreach($notice_list as &$notice){
			$notice['createtime']=date('Y-m-d h:i',$notice['createtime']);
		}
	}
	$return['notice_list']=$notice_list;
	$sharelink='jy_weishop/sale.kabao//fromuser='.$_SESSION['uid'];
	$return['sharedata']=array(
		'title'=>$setting['share_title']?$setting['share_title']:'首页-在线礼包',
		'desc'=>$setting['share_desc']?$setting['share_desc']:'在线礼包，一个属于自己的个人礼包！',
		'link'=>custom_url($sharelink,true),
		'imgUrl'=>tomedia($setting['share_image'])
	);
	set_html('keywords',$page['keywords']?:$return['setting']['share_keywords']);
	exi($return);
}
if($_RQ['op']=='getlist'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1);
	if($_RQ['pid']){
		$params['groupid']=$_RQ['pid'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_weishop_goods_package',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as &$item){
		$item['image']=tomedia($item['image']);
		$item['images']=json_decode($item['images'],true);
	}
	$return['list']=$list;
	exi($return);
}
?>